//package com.yunhe.device.controller.base;
//
//import com.yunhe.device.domain.base.BatteryType;
//import com.yunhe.common.exception.ArgumentErrorException;
//import com.yunhe.common.exception.ObjectNotFoundException;
//import com.yunhe.common.exception.UniqueConstraintsException;
//import com.yunhe.common.model.ResultObject;
//import com.yunhe.device.service.base.BatteryTypeService;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiImplicitParam;
//import io.swagger.annotations.ApiImplicitParams;
//import io.swagger.annotations.ApiOperation;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.http.HttpStatus;
//import org.springframework.http.ResponseEntity;
//import org.springframework.web.bind.annotation.*;
//
//import java.util.Optional;
//
///**
// * 电池类型Controller
// * @author liuronglei
// */
//@Api(value = "batteryType", description = "电池类型_枚举维护", tags = {"Base_BatteryType"})
//@RestController
//@RequestMapping("/{systemId}/batteryTypes")
//public class BatteryTypeController {
//    @Autowired
//    private BatteryTypeService batteryTypeService;
//
//    /**
//     * 新增电池类型
//     * @param batteryType 电池类型对象
//     */
//    @ApiOperation("新增电池类型")
//    @RequestMapping(method = RequestMethod.POST)
//    public ResponseEntity<ResultObject> post(
//            @RequestBody BatteryType batteryType)
//            throws ArgumentErrorException, UniqueConstraintsException {
//        BatteryType newBatteryType = batteryTypeService.createBatteryType(batteryType);
//        return new ResponseEntity<>(new ResultObject<>(newBatteryType), HttpStatus.OK);
//    }
//
//    /**
//     * 根据电池类型ID删除电池类型
//     * @param id 电池类型ID
//     */
//    @ApiOperation("根据电池类型ID删除电池类型")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "电池类型ID", required = true, dataType = "Long", paramType = "path")
//    })
//    @RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
//    public ResponseEntity<ResultObject> delete(
//            @PathVariable("id") Long id) {
//        batteryTypeService.deleteBatteryType(id);
//        return new ResponseEntity<>(new ResultObject<>(null), HttpStatus.OK);
//    }
//
//    /**
//     * 更新电池类型
//     * @param id 电池类型ID
//     * @param batteryType 电池类型对象
//     */
//    @ApiOperation("更新电池类型")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "电池类型ID", required = true, dataType = "Long", paramType = "path")
//    })
//    @RequestMapping(value = "/{id}", method = RequestMethod.PUT)
//    public ResponseEntity<ResultObject> put(
//            @PathVariable("id") Long id,
//            @RequestBody BatteryType batteryType)
//            throws ArgumentErrorException, ObjectNotFoundException, UniqueConstraintsException {
//        batteryType.setId(id);
//        BatteryType newBatteryType = batteryTypeService.updateBatteryType(batteryType);
//        return new ResponseEntity<>(new ResultObject<>(newBatteryType), HttpStatus.OK);
//    }
//
//    /**
//     * 更新电池类型
//     * @param id 电池类型ID
//     * @param name 电池类型代码
//     * @param title 电池类型名称
//     * @param activity 是否可用
//     */
//    @ApiOperation("更新电池类型")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "电池类型ID", required = true, dataType = "Long", paramType = "path"),
//            @ApiImplicitParam(name = "name", value = "电池类型代码", dataType = "String", paramType = "query"),
//            @ApiImplicitParam(name = "title", value = "电池类型名称", dataType = "String", paramType = "query"),
//            @ApiImplicitParam(name = "activity", value = "是否可用", dataType = "Boolean", paramType = "query")
//    })
//    @RequestMapping(value = "/{id}", method = RequestMethod.PATCH)
//    public ResponseEntity<ResultObject> patch(
//            @PathVariable("id") Long id,
//            @RequestParam("name") Optional<String> name,
//            @RequestParam("title") Optional<String> title,
//            @RequestParam("activity") Optional<Boolean> activity)
//            throws ArgumentErrorException, ObjectNotFoundException, UniqueConstraintsException {
//        BatteryType newBatteryType = batteryTypeService.updateBatteryType(id, name.orElse(null), title.orElse(null), activity.orElse(null));
//        return new ResponseEntity<>(new ResultObject<>(newBatteryType), HttpStatus.OK);
//    }
//
//    /**
//     * 根据电池类型ID获得电池类型
//     * @param id 电池类型ID
//     */
//    @ApiOperation("根据电池类型ID获得电池类型")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "电池类型ID", required = true, dataType = "Long", paramType = "path")
//    })
//    @RequestMapping(value = "/{id}", method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> get(
//            @PathVariable("id") Long id) {
//        BatteryType batteryType = batteryTypeService.findByBatteryTypeId(id);
//        return new ResponseEntity<>(new ResultObject<>(batteryType), HttpStatus.OK);
//    }
//
//    /**
//     * 根据条件获得电池类型列表
//     */
//    @ApiOperation("根据条件获得电池类型列表")
//    @RequestMapping(method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> search() {
//        Iterable<BatteryType> results = batteryTypeService.findBatteryTypes();
//        return new ResponseEntity<>(new ResultObject<>(results), HttpStatus.OK);
//    }
//}